﻿using Anonym.Models.Common;
using System;
using System.Collections.Generic;
using System.Text;

namespace Anonym.Common
{
    /// <summary>
    /// 通用方法
    /// </summary>
    public class Tools
    {
        public static Dictionary<string, string> EnumModelToDictionary(Type em)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            foreach (int myCode in Enum.GetValues(em))
            {
                string strName = Enum.GetName(em, myCode);//获取名称
                string strVaule = myCode.ToString();//获取值
                dic.Add(strName, strVaule);
            }
            return dic;
        }

        public static List<SelectItem> EnumModelToSelectItem(Type em)
        {
            List<SelectItem> siList = new List<SelectItem>();
            foreach (int myCode in Enum.GetValues(em))
            {
                SelectItem si = new SelectItem();
                si.Name = Enum.GetName(em, myCode); //获取名称
                si.Val = myCode.ToString(); //获取值
                siList.Add(si);
            }
            return siList;
        }

    }
}
